package com.scz;

import org.mybatis.spring.annotation.MapperScan;
import org.springframework.web.WebApplicationInitializer;
import org.springframework.web.context.support.AnnotationConfigWebApplicationContext;
import org.springframework.web.servlet.DispatcherServlet;

import javax.servlet.ServletContext;
import javax.servlet.ServletRegistration;

/**
 * @author Acer
 */

/**
 * Web应用程序初始化类
 * @author scz
 */
@MapperScan("com.scz.mapper")
public class HouseKeepingApplication implements WebApplicationInitializer {
    @Override
    public void onStartup(ServletContext servletContext) {
        // 创建Spring的IOC容器
        AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext();
        context.setServletContext(servletContext);
        // 注册Spring MVC的DispatcherServlet
        ServletRegistration.Dynamic dispatcher = servletContext.addServlet("dispatcher",
                new DispatcherServlet(context));
        dispatcher.setLoadOnStartup(1);
        dispatcher.addMapping("/");
    }
}
